<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-xs12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="tabZZT">
                        <ul class="layui-tab-title">
                            <li class="layui-this">平台统计</li>
                        </ul>
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form">
                                <div class="layui-row">
                                    <div class="layui-col-md4" style="width: 8.333333%;">
                                        <div class="layui-form-item" style="margin-top: 30px;width: 110px;">
                                            <select id="statusId" lay-filter="time" >
                                                <option value="0">最近一周</option>
                                                <option value="1">最近一个月</option>
                                                <option value="2">最近三个月</option>
                                                <option value="3">最近半年</option>
                                                <option value="4">最近一年</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-col-md4" style="width:23.6667%">
                                        <div class="layui-form-item" style="margin-top: 30px;width: 140px;">
                                            <select id="countType" lay-filter="countTypeSel">
                                                <option value="system">系统(平台操作)</option>
                                                <option value="singleAmount">抢单金额</option>
                                                <option value="applyCash">提现</option>
                                                <option value="transfer">划转</option>
                                                <option value="singleAmountThaw">抢单金额解冻</option>
                                                <option value="profitShareholderPool">利润进入股东池</option>
                                                <option value="singleProfit">抢单利润</option>
                                                <option value="commissionMargins">佣金利润</option>
                                                <option value="levelService">平级服务</option>
                                                <option value="profitsTransfer">利润余额划转</option>
                                                <option value="idleTransfer">闲置余额划转</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-col-md4">
                                        <div class="layui-form-item" style="margin-top: 30px;">
                                            <label class="layui-form-label" style="width: 100%;text-align: center;">交易总额：<span id="totalCount"></span></label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row layui-col-space30">
                                <div class="layui-col-xs12">
                                    <div id="statisticXse" style="height: 500px;"></div>
                                </div>
                                <div class="layui-col-xs12 layui-col-md4">
                                    <table class="layui-table" lay-skin="nob">
                                        <colgroup>
                                            <col width="50">
                                            <col>
                                            <col width="96">
                                        </colgroup>
                                        <thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

</div>


<!-- js部分 -->
<script src="/admin/assets/libs/echarts/echarts.min.js"></script>
<script src="/admin/assets/libs/echarts/echartsTheme.js"></script>

<script>
    layui.use(['layer', 'element', 'config', 'admin', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var element = layui.element;
        var config = layui.config;
        var admin = layui.admin;
        var form = layui.form;

        form.render('select');
        req(0);

        form.on('select(time)', function(data){
            req(data.value,$("#countType").val());
        });

        form.on('select(countTypeSel)', function(data){
            req($("#statusId").val(),data.value);
        });

        function req(type,countType){
            layer.load(2);
            admin.req('user/admin/statistic/list', {access_token: config.getToken(), type:type,countType:countType}, function (res) {
                layer.closeAll('loading');
                if (res.code == 200) {
                    console.log($("#totalCount"));
                    $("#totalCount").html(res.data.totalCount);
                    showCharts(res.data.dateArray, res.data.dataArray);
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'GET');
        }

        function showCharts(dateArray, dataArray) {
            // 渲染销售额图表
            var myCharts = echarts.init(document.getElementById('statisticXse'), myEchartsTheme);
            var option3 = {
                title: {
                    text: '',
                    textStyle: {
                        color: '#000',
                        fontSize: 14
                    }
                },
                tooltip: {},
                grid: {
                    left: '0',
                    right: '0',
                    bottom: '0',
                    containLabel: true
                },
                xAxis: {
                    data: dateArray
                },
                yAxis: {},
                series: [{
                    type: 'line',
                    data: dataArray,
                    barMaxWidth: 45
                }]
            };
            myCharts.setOption(option3);

            // 窗口大小改变事件
            window.onresize = function () {
                myCharts.resize();
            };
        }
    });
</script>